
// 创建一个事件总线用于触发侧边栏刷新
export const sidebarEvents = {
  callbacks: [] as (() => void)[],

  // 注册刷新回调
  register(callback: () => void) {
    this.callbacks.push(callback);
    return () => {
      const index = this.callbacks.indexOf(callback);
      if (index !== -1) {
        this.callbacks.splice(index, 1);
      }
    };
  },

  // 触发所有刷新回调
  refreshAll() {
    this.callbacks.forEach(callback => callback());
  }
};

